const directives = {};

export function directive(name, hooks) {
  directives[name] = hooks;
}

export function applyDirectives(vnode) {
  if (vnode.props) {
    Object.keys(vnode.props).forEach(prop => {
      if (prop.startsWith('v-')) {
        const directiveName = prop.slice(2);
        const directive = directives[directiveName];
        if (directive) {
          directive.bind(vnode.el, vnode.props[prop], vnode);
        }
      }
    });
  }
}